layui.use("laydate", () => {
    let laydate = layui.laydate;
    //日期时间范围
    laydate.render({
        elem: '#startDate'
        , type: 'datetime'
    });
    laydate.render({
        elem: '#endDate'
        , type: 'datetime'
    });
    let dict = expansionsDict();
    let cols = [[
        {type: 'checkbox', fixed: 'left'}
        , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
        , {field: 'code', title: '账户', width: 120, align: 'center'}
        , {field: 'name', title: '姓名', width: 80, align: 'center'}
        , {field: 'age', title: '年龄', width: 80, sort: true, align: 'center'}
        , {
            field: 'sex', title: '性别', width: 80, sort: true, align: 'center', templet: (e) => {
                return dict.sex[e.sex];
            }
        }
        , {
            field: 'teamId', title: '小组', width: 120, align: 'center', templet: (e) => {
                return isEmpty(dict.teamId[e.teamId]) ? "" : dict.teamId[e.teamId];
            }
        }
        , {
            field: 'degree', title: '学历', align: 'center', templet: (e) => {
                return dict.degree[e.degree];
            }
        }
        , {field: 'graduateSchool', title: '毕业院校', align: 'center'}
        , {field: 'address', title: '住址', align: 'center'}
        , {field: 'phone', title: '手机', align: 'center'}
        , {
            field: 'headImg', title: '头像', align: 'center', templet: (e) => {
                return "<img src='" + (isEmpty(e.headImg) ? "/img/nullHeadImg.png" : e.headImg) + "' > ";
            }
        }
        , {
            field: 'status', title: '状态', width: 80, sort: true, align: 'center', templet: (e) => {
                return dict.status[e.status];
            }
        }
        , {field: 'createTime', title: '注册时间', width: 150, sort: true, align: 'center'}
        , {field: 'updateTime', title: '更新时间', width: 150, align: 'center'}
        , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150, align: 'center'}
    ]];
    render("userTable", {
        "query": "/admin/user/query",
        "delete": "/admin/user/delete",
        "batchDelete": "/admin/user/batchDelete",
        "template": "../user/userUpdate.html",
        "select": {"teamId": "/admin/team/selectMap"}
    }, "用户", cols, ['40%', '72%']);

    function expansionsDict() {
        let dict = getDict();
        ajax("/admin/team/selectMap", "GET", "", (res) => {
            if (res.code === 0) {
                dict["teamId"] = res.data;
                ajax("/admin/role/selectMap", "GET", "", (res) => {
                    if (res.code === 0) {
                        dict["roleCode"] = res.data;
                        queryFormSelectRender(queryForm, dict);
                    }
                });
            }
        });
        return dict;
    }
});